package com.fh.service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fh.model.Product;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

@Service
@RabbitListener(queues = {"queue5","queue4"})
public class ConsumerMsgService {

    @RabbitHandler
    public void  ConsumerMsg(String msg) throws JsonProcessingException {
        ObjectMapper objectMapper=new ObjectMapper();
        Product product = objectMapper.readValue(msg, Product.class);

        System.out.println("接收到的消息为"+product);
    }
}
